package com.mxchip.livestarmobile.mobile.state;

import androidx.annotation.NonNull;

public class SystemData {
    // public static String roomId = Hawk.get(AppConstant.SP_LUXX_ROOM_ID);// "default";
    // public static String userId = Hawk.get(AppConstant.SP_LUXX_NUMBER); // Utils.getAllCode();
    public static final String clientType = "android";
    // public static String oldUserId = Utils.getUserId();
    // public static String deviceId = DeviceInfo.getDeviceSN();
    public static boolean globalIsAuth = true;
    // public static boolean isCaller = false;
    // private int currentState;
    private int streamMode;
    private boolean cameraRelease = true;
    // private static final FileLog logger = FileLog.getLogger(SystemData.class);
    public static boolean autoAnswer;


    public boolean isCameraRelease() {
        return cameraRelease;
    }

    public void setCameraRelease(boolean cameraRelease) {
        this.cameraRelease = cameraRelease;
    }

    // public StateMachineTable table = new StateMachineTable();
    private static SystemData instance = new SystemData();

    // List<String> statelist = new ArrayList<>();

    // List<String> eventList = new ArrayList<>();

    private SystemData() {

        /*eventList.add("connect");
        eventList.add("registerTimeOut");
        eventList.add("rcvRegisterAck");
        eventList.add("dialUpBtnClick");
        eventList.add("rcvInviteRequestAck");

        eventList.add("rcvInviteAccept");
        eventList.add("inviteAcceptAck");
        eventList.add("inviteAcceptNack");
        eventList.add("mulDialUpBtnClick");
        eventList.add("rcvMulInviteRequestAck");

        eventList.add("RcvInviteNotify");
        eventList.add("AcceptBtnClick");
        eventList.add("RefuseBtnClick");
        eventList.add("RcvInviteNotifyCallback");
        eventList.add("RcvInviteNotifyNew");

        eventList.add("hdmiInDetected");
        eventList.add("rcvResPubAck");
        eventList.add("hdmiInOut");
        eventList.add("rcvResCloseAck");
        eventList.add("hungupBtnClick");

        eventList.add("offlineHungupBtnClick");
        eventList.add("RcvResNotify");
        eventList.add("rcvRelease");
        eventList.add("disconnect");
        eventList.add("loginSuccess");*/

        /*statelist.add(*//*"OFFLINE"*//*Appli.getContext().getString(R.string.not_online));
        statelist.add(*//*"IDLE"*//*Appli.getContext().getString(R.string.idle));
        statelist.add(*//*"CALLING"*//*Appli.getContext().getString(R.string.in_call));
        statelist.add(*//*"BE_CALLED"*//*Appli.getContext().getString(R.string.be_called));
        statelist.add(*//*"BUSY"*//*Appli.getContext().getString(R.string.calling));*/
        /*//连接
    public static int connect = 0;
    //注册
    public static int registerTimeOut = 1;
    public static int rcvRegisterAck = 2;

    //主叫发起邀请请求
    public static int dialUpBtnClick = 3;
    public static int rcvInviteRequestAck = 4;
    public static int rcvInviteAccept = 5;
    public static int inviteAcceptAck = 6;
    public static int inviteAcceptNack = 7;
    public static int mulDialUpBtnClick = 8;
    public static int rcvMulInviteRequestAck = 9;
    //被叫
    public static int RcvInviteNotify = 10;
    public static int AcceptBtnClick = 11;
    public static int RefuseBtnClick = 12;
    public static int RcvInviteNotifyCallback = 13;

    //主动资源
    public static int hdmiInDetected = 14;
    public static int rcvResPubAck = 15;
    public static int hdmiInOut = 16;
    public static int rcvResCloseAck = 17;
    public static int hungupBtnClick = 18;
    //被动资源
    public static int RcvResNotify = 19;


    //释放
    public static int rcvRelease = 20;*/
    }

    public static SystemData getInstance() {
        return instance;
    }

    /*public void sm_evthandle(int evt, Object... body) {
        int size = table.machines.size();
        MyLog.logD("\nSystemData::" + "sm_evthandle start:\n  \tcurrentState:" + currentState + " currentEvent:" + eventList.get(evt) + "\n\n\n");
        logger.info(new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss", Locale.CHINA).format(new Date()) + "SystemData::" + "sm_evthandle start:\n  currentState:" + currentState + " currentEvent:" + eventList.get(evt));
        for (int i = 0; i < size; i++) {
            if (table.machines.get(i).state == currentState && table.machines.get(i).event == evt) {
                StateMachine stateMachine = table.machines.get(i);
                boolean execute;
                if (body != null) {
                    execute = stateMachine.getAction().execute(body);
                } else {
                    execute = stateMachine.getAction().execute();
                }
                if (execute) {
                    currentState = stateMachine.getNextState();
                    // RxBus.get().post(RxConstant.NET_STATE, statelist.get(currentState));
                }
                break;
            }
        }
        MyLog.logD("SystemData::" + "sm_evthandle end:\n  \tcurrentState:" + currentState + " currentEvent:" + eventList.get(evt) + "\n");
        logger.info(new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss", Locale.CHINA).format(new Date()) + "SystemData::" + "sm_evthandle end:\n  currentState:" + currentState + " currentEvent:" + eventList.get(evt));
    }*/

    /*public int getCurrentState() {
        return currentState;
    }*/

    /*public void setCurrentState(int currentState) {
        this.currentState = currentState;
    }*/

    /*public String getState() {
        return statelist.get(currentState);
    }*/

    public int getStreamMode() {
        return streamMode;
    }

    /**
     * 接收到来自无线投屏按键的指令
     */
    private boolean wifiResPub = false;

    public boolean getWifiResPub() {
        return wifiResPub;
    }

    public void setWifiResPub(boolean wifiResPub) {
        this.wifiResPub = wifiResPub;
    }

    /**
     * 收到来自资源发送方的关闭打开指令
     */
    private boolean receiveWifiResState = false;

    public boolean getReceiveWifiResState() {
        return receiveWifiResState;
    }

    public void setReceiveWifiResState(boolean wifiResCloseTime) {
        this.receiveWifiResState = wifiResCloseTime;
    }

    /**
     * 资源的初始化释放工作是否完成
     */
    private boolean mediaCodecReadyState = true;

    public boolean getMediaCodecReadyState() {
        return mediaCodecReadyState;
    }

    public void setMediaCodecReadyState(boolean mediaCodecResState) {
        this.mediaCodecReadyState = mediaCodecResState;
    }

    public void setStreamMode(int streamMode) {
        this.streamMode = streamMode;
    }

    private long hangupTime;

    public void setHangupTime(long currentTimeMillis) {
        hangupTime = currentTimeMillis;
    }

    public long getHangupTime() {
        return hangupTime;
    }


    public static int networkLevelStandard = 0;
    public static int networkLevelMiddle = 1;
    public static int networkLevelLower = 2;
    public static int networkLevelMinimum = 3;

    public static int standardBitRate = 1024 * 1024 * 3 / 2;
    public static int middleBitRate = (int) (1024 * 1024 * 0.8);
    public static int lowerBitRate = 1024 * 512;
    public static int minimumBitRate = (int) (1024 * 1024 * 0.3);

    public static int cameraStandardBitRate = 1024 * 500;
    public static int cameraMiddleBitRate = 1024 * 300;
    public static int cameraLowerBitRate = 1024 * 200;
    public static int cameraMinimumBitRate = 1024 * 100;


    public static @NonNull String deviceId() {
        String val = DeviceInfo.getDeviceSN();
        if(val == null) {
            return "";
        }
        return val;
    }

    public static @NonNull String userId() {
        String val = SPreference.getDeviceNumber();
        if(val == null) {
            return "";
        }
        return val;
    }

    public static @NonNull String roomId() {
        String val = SPreference.getDeviceRoomId();
        if(val == null) {
            return "";
        }
        return val;
    }
}
